home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1998
/
MacHack 1998.toast
/
Sessions
/
STL
/
Slides
/
STL10.cp
< prev
next >
Wrap
Text File
|
1998-06-19
|
420b
|
20 lines
// STL10.cp
#include <string>
using namespace std;
int main()
{
string a = "shared string";
string b(a); // a and b are sharing the same string buffer
if (a[0] != b[0]) // line 1
{
a = b = "un" + a; // line 2
}
if (a.c_str()[0] == b.c_str()[0]) // line 3
{
a = b = "un" + a; // line 4
}
// a and b are no longer sharing the same string buffer
// Question: At what line is the buffer copied?
}